package com.zq.sysuser.controller;


import com.github.pagehelper.PageInfo;
import com.zq.common.util.Result;
import com.zq.sysuser.dao.entity.SysOperLog;
import com.zq.sysuser.dao.entity.Useractions;
import com.zq.sysuser.service.ISysOperLogService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;

/**
 * <p>
 * 操作日志记录 前端控制器
 * </p>
 *
 * @author 张乔
 * @since 2025-05-28
 */
@RestController
@RequestMapping("/sys/sys-oper-log")
public class SysOperLogController {


    @Resource
    private ISysOperLogService sysOperLogService;


//    分页条件查询日志记录
@GetMapping("/getPageList/{page}/{limit}")
public Result<PageInfo<SysOperLog>> getPageList(@PathVariable Integer page,
                          @PathVariable Integer limit,
                          @RequestParam("userName")String userName) {

PageInfo<SysOperLog> pageInfo= sysOperLogService.getPageList(page, limit, userName);
    return Result.successData(pageInfo);


}

    @PostMapping("/save")
    public Result<String> add(@RequestBody SysOperLog useractions) {
        useractions.setCreateTime(LocalDateTime.now());
        sysOperLogService.save(useractions);
        return Result.success();
    }

    @PutMapping("/update")
    public Result<String> update(@RequestBody SysOperLog useractions) {
        sysOperLogService.updateById(useractions);
        return Result.success();
    }
    @DeleteMapping("/deleteById/{id}")
    public Result<String> delete(@PathVariable Long id) {
        sysOperLogService.removeById(id);
        return Result.success();

    }


}
